#include "gamehall.h"
#include "ui_gamehall.h"
#include "gameselect.h"

GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameHall)
{
    ui->setupUi(this);
    this->setFixedSize(1200,900);
    this->setWindowIcon(QIcon(":res/ico.png"));
    this->setWindowTitle("贪吃蛇大作战");

    QPushButton *strBtn = new QPushButton(this);
    strBtn->move(this->width() * 0.5 - strBtn->width(),this->height() * 0.8);
    strBtn->setText("开始游戏");
    QFont font("方正舒体",40);
    strBtn->setFont(font);
    strBtn->setStyleSheet("QPushButton{border:0px;}");

    connect(strBtn,&QPushButton::clicked,[=](){
        GameSelect *gameSelect = new GameSelect;
        this->close();
        gameSelect->setGeometry(this->geometry());
        gameSelect->show();

        QSound::play(":res/clicked.wav");
    });
}

GameHall::~GameHall()
{
    delete ui;
}

void GameHall::paintEvent(QPaintEvent *event)
{
    //游戏大厅
    QPainter painter(this);
    QPixmap pix(":res/game_hall.jpg");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}

